package com.j2eefast.flowable.erp.service;


import com.j2eefast.flowable.erp.entity.bpmErpPersonReimburseEntity;
import com.j2eefast.flowable.erp.mapper.bpmErpPersonReimburseMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * ERP人事报销Service接口
 * @author: yhli
 * @date 2020-07-16 10:30
 */
@Service
public class bpmErpPersonReimburseService extends ServiceImpl<bpmErpPersonReimburseMapper,bpmErpPersonReimburseEntity> {

	@Resource
	private bpmErpPersonReimburseMapper bpmErpPersonReimburseMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmErpPersonReimburseEntity> queryWrapper = new QueryWrapper<bpmErpPersonReimburseEntity>();
           String serialNumber = (String) params.get("serialNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(serialNumber), "serial_number", serialNumber);
             String applyUsername = (String) params.get("applyUsername");
        queryWrapper.like(ToolUtil.isNotEmpty(applyUsername), "apply_username", applyUsername);
                         String reimburseCostTime = (String) params.get("reimburseCostTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseCostTime), "reimburse_cost_time", reimburseCostTime);
          String reimburseMoney = (String) params.get("reimburseMoney");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseMoney), "reimburse_money", reimburseMoney);
                         String managerReimburseProportion = (String) params.get("managerReimburseProportion");
         queryWrapper.eq(ToolUtil.isNotEmpty(managerReimburseProportion), "manager_reimburse_proportion", managerReimburseProportion);
          String managerReimburseMoney = (String) params.get("managerReimburseMoney");
         queryWrapper.eq(ToolUtil.isNotEmpty(managerReimburseMoney), "manager_reimburse_money", managerReimburseMoney);
                       		Page<bpmErpPersonReimburseEntity> page = bpmErpPersonReimburseMapper.selectPage(new Query<bpmErpPersonReimburseEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmErpPersonReimburseEntity bpmErpPersonReimburseEntity) {
		Page<bpmErpPersonReimburseEntity> page = bpmErpPersonReimburseMapper.findPage(new Query<bpmErpPersonReimburseEntity>(params).getPage(), bpmErpPersonReimburseEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmErpPersonReimburseByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmErpPersonReimburseById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmErpPersonReimburse(bpmErpPersonReimburseEntity bpmErpPersonReimburse){
        return save(bpmErpPersonReimburse);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmErpPersonReimburseById(bpmErpPersonReimburseEntity bpmErpPersonReimburse) {
		return updateById(bpmErpPersonReimburse);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmErpPersonReimburseEntity getbpmErpPersonReimburseById(String id){
		return getById(id);
	}
}
